<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var arr = [5, 2, 1, 4, 3];
        var temp;
        for (var i = 0; i <= arr.length - 1; i++) { //外层循环管趟数
            for (var j = 0; j <= arr.length - i - 1; j++) {//里层管每趟交换次数
                //内部交换2个变量的值 第一个人
                if (arr[j] < arr[j + 1]) {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;

                }
            }
        }
        console.log(arr);
    </script>
</head>
<body>

</body>
</html>